import {NgModule} from '@angular/core';
import {Routes, RouterModule} from '@angular/router';
import {FirstComponent} from './first/first.component';
import {SecondComponent} from './second/second.component';
import {EmptyComponent} from './empty/empty.component';
import {ChildAComponent} from './first/child-a/child-a.component';
import {ChildBComponent} from './first/child-b/child-b.component';
import {YourGuardGuard} from "./your-guard.guard";

const routes: Routes = [
  {
    path: 'first', component: FirstComponent,
    children: [
      {
        path: 'child-a', // child route path
        component: ChildAComponent // child route component that the router renders
      },
      {
        path: 'child-b',
        component: ChildBComponent // another child route component that the router renders
      }
    ]
  },
  {path: 'second', component: SecondComponent,
  canActivate: [YourGuardGuard]},
  // { path: '',   redirectTo: '/first', pathMatch: 'full' }, // redirect to `first-component`
  {path: '**', component: EmptyComponent}, // 无路由匹配时的时空页面
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {
}
